
        //正则
        let usernameReg = /^1[3-9][0-9]{9}$/
        let pswReg = /^[a-z0-9_-]{6,20}$/
        let enter_name = $('.enter_name')[0]
        let enter_psw = $('.enter_psw')[0]
        let enter_psw2 = $('.enter_psw2')[0]
        function register() {
            //用户名、密码正则验证功能
            let username = $('.username')[0]
            let password = $('.password')[0]
            let password_agin = $('.password_agin')[0]
            // let strength = $('.strength')[0]
            // let pb = $('.pb')[0]
            username.onfocus = function () {
                enter_name.innerHTML = '请填写您的手机号'
                enter_name.style.display = 'block'
            }
            username.onblur = function () {
                if (usernameReg.test(username.value)) {
                    enter_name.style.display = 'none'
                } else {
                    enter_name.innerHTML = '请输入正确的手机号！'
                }
            }
            password.onfocus = function () {
                enter_psw.innerHTML = '密码必须输入6-20位字符'
                enter_psw.style.display = 'block'
              
            }
            password.onblur = function () {
                
                if (pswReg.test(password.value)) {
                    enter_psw.style.display = 'none'
                } else {
                    enter_psw.innerHTML = '请输入6-20位字符！'
                }
            }
            password_agin.onfocus = function () {
                enter_psw2.innerHTML = '请再次输入密码'
                enter_psw2.style.display = 'block'
            }
            password_agin.onblur = function () {
                let password = $('.password')[0].value
                let password_agin = $('.password_agin')[0].value
                if (password == password_agin) {
                    enter_psw2.style.display = 'none'
                } else {
                    enter_psw2.innerHTML = '两次输入密码不一致'
                }
            }
            //注册功能
            let loginBtn = $('.b2')[0]
            loginBtn.onclick = () => {
                let username = $('.username')[0].value
                let password = $('.password')[0].value
                let password_agin = $('.password_agin')[0].value
                if (password == password_agin) {
                    if (usernameReg.test(username) && pswReg.test(password)) {
                        let list = [{ username, password }]
                        localStorage.setItem('login', JSON.stringify(list))
                        alert('注册成功，现在去登录吧！')
                        location.href = '/html/login.html'
                    } else {
                        enter_psw2.innerHTML = '用户名或密码格式不正确'
                    }
                } else {
                    enter_psw2.innerHTML = '两次输入密码不一致'
                    return
                }
            }
        }
        register()
